package Gameplay.Enemy;

import ADTs.PointADT;
import Gameplay.Level;
import Gameplay.Projectile.Projectile;
import Project.Main;

	
public class AI2 extends AI {
	
	int fireRotation;
	
	public AI2()
	{
		super();
		this.cooldown = 300;
		this.lastFired = 0;
		fireRotation = 0;
	}
	
	public boolean move(Enemy e){
		return true;
	}
	/*@ requires enemyShootPathClean = true;
	  @	Projectile.aim.x = Player.x
	  @	Projectile.aim.y = Player.y
	  @*/
	public void attack(Enemy e){
		if(lastFired + cooldown < System.currentTimeMillis()) {
			if(fireRotation == 0) {
				((Level) Main.getCurrentUI()).addToState(new Projectile(new PointADT(1,0), e.getLocation().copy(), false));
				((Level) Main.getCurrentUI()).addToState(new Projectile(new PointADT(-1,0), e.getLocation().copy(), false));
				((Level) Main.getCurrentUI()).addToState(new Projectile(new PointADT(0,1), e.getLocation().copy(), false));
				((Level) Main.getCurrentUI()).addToState(new Projectile(new PointADT(0,-1), e.getLocation().copy(), false));
				fireRotation = 1;
			} else if(fireRotation == 1) {
				((Level) Main.getCurrentUI()).addToState(new Projectile(new PointADT(1,1), e.getLocation().copy(), false));
				((Level) Main.getCurrentUI()).addToState(new Projectile(new PointADT(1,-1), e.getLocation().copy(), false));
				((Level) Main.getCurrentUI()).addToState(new Projectile(new PointADT(-1,1), e.getLocation().copy(), false));
				((Level) Main.getCurrentUI()).addToState(new Projectile(new PointADT(-1,-1), e.getLocation().copy(), false));
				fireRotation = 0;
			}
			
			lastFired = System.currentTimeMillis();
		}
	}
} 
